package cn.itsource.hrm.fallback;

import cn.itsource.hrm.doc.CourseDoc;
import cn.itsource.hrm.feign.CourseFeign;
import cn.itsource.hrm.util.AjaxResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class FallbackCourseFeign implements FallbackFactory<CourseFeign>{
    @Override
    public CourseFeign create(Throwable throwable) {
        return new CourseFeign() {
            @Override
            public AjaxResult save(CourseDoc doc) {
                log.error("搜索服务不可用,方法：{}，参数：{}","save",doc);
                return AjaxResult.me().setSuccess(false).setMessage("保存课程失败");
            }
        };
    }
}
